const { users: usersModel } = require('../models')

const addService = async (username, password) => {
  return await usersModel.create({
    username,
    password
  })
}

const findOneService = async (_id) => {
  return await usersModel.findOne({ _id })
}

const updateOneService = async (_id, username, password) => {
  return await usersModel.updateOne({ _id }, {
    username,
    password
  })
}

const deleteOneService = async (_id) => {
  return await usersModel.deleteOne({ _id })
}

module.exports = {
  addService,
  findOneService,
  updateOneService,
  deleteOneService
}